﻿<UserControl x:Class="FaceTracking3D.TexturedFaceMeshViewer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:l="clr-namespace:FaceTracking3D"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Image Name="ColorImage" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
        <Viewport3D Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" x:Name="viewport3d" RenderTransformOrigin="0.5,0.5" >
            <Viewport3D.RenderTransform>
                <ScaleTransform ScaleX="2.0" ScaleY="2.0"></ScaleTransform>
            </Viewport3D.RenderTransform>
            <!-- Defines the camera used to view the 3D object. -->
            <Viewport3D.Camera>
                <PerspectiveCamera Position="0,0,0" LookDirection="0,0,-1" FieldOfView="60" />
            </Viewport3D.Camera>

            <!-- The ModelVisual3D children contain the 3D models -->
            <Viewport3D.Children>

                <!-- This ModelVisual3D defines the light cast in the scene. Without light, the 3D 
                   object cannot be seen. Also, the direction of the lights affect shadowing. If desired,
                   you can create multiple lights with different colors that shine from different directions. -->
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <DirectionalLight Color="#FFFFFF" Direction="-0.5,-0.5,-0.5" />
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <GeometryModel3D>

                            <!-- The geometry specifes the shape of the 3D plane. In this sample, a flat sheet is created. -->
                            <GeometryModel3D.Geometry>
                                <MeshGeometry3D x:Name="theGeometry"
                       TriangleIndices="0,1,2 3,4,5 "
                       Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
                       TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
                       Positions="-0.25,-0.25,-1   0.25,-0.25,-1    0.25,0.25,-1    0.25,0.25,-1    -0.25,0.25,-1    -0.25,-0.25,-1 " />
                            </GeometryModel3D.Geometry>

                            <!-- The material specifies the material applied to the 3D object. In this sample a linear gradient 
                         covers the surface of the 3D object.-->
                            <GeometryModel3D.Material>
                                <MaterialGroup>
                                    <DiffuseMaterial x:Name="theMaterial">
                                        <DiffuseMaterial.Brush>
                                            <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                                                <LinearGradientBrush.GradientStops>
                                                    <GradientStop Color="Yellow" Offset="0" />
                                                    <GradientStop Color="Red" Offset="0.25" />
                                                    <GradientStop Color="Blue" Offset="0.75" />
                                                    <GradientStop Color="LimeGreen" Offset="1" />
                                                </LinearGradientBrush.GradientStops>
                                            </LinearGradientBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                </MaterialGroup>
                            </GeometryModel3D.Material>

                            <!-- Apply a transform to the object. In this sample, a rotation transform is applied, rendering the 
                         3D object rotated. -->
                            <GeometryModel3D.Transform>
                                <RotateTransform3D>
                                    <RotateTransform3D.Rotation>
                                        <AxisAngleRotation3D Axis="0,3,0" Angle="0" />
                                    </RotateTransform3D.Rotation>
                                </RotateTransform3D>
                            </GeometryModel3D.Transform>
                        </GeometryModel3D>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
            </Viewport3D.Children>

        </Viewport3D>
    </Grid>
</UserControl>
